package game.scene.timer;

import game.scene.AbstractScene;
import game.scene.ninegrid.Area;
import game.scene.ninegrid.TowerScene;

import java.util.Iterator;
import java.util.Map;

/**
 * @author : [zhaojianbo]
 * @version : [v1.0]
 * @className : [AreaRemoveTimer]
 * @description :AreaRemoveTimer
 * @createTime : 2025/7/1
 */
public class AreaRemoveTimer implements Runnable {
    Map<Long, TowerScene> sceneMap;

    public AreaRemoveTimer(Map<Long, TowerScene> sceneMap) {
        this.sceneMap = sceneMap;
    }

    @Override
    public void run() {
        sceneMap.values().stream().filter(e -> e.areaRemove).forEach(scene -> {
            Iterator<Area> itr = scene.areas.values().iterator();
            while (itr.hasNext()) {
                Area area = itr.next();
                if (area.destroyTime > System.currentTimeMillis()) {
                    itr.remove();
                }
            }
        });
    }
}
